let books=[
    {
      "id": 1,
      "title": "Node.js开发指南",
      "author": "李锴",
      "price": "59.80",
      "publisher": "人民邮电出版社",
      "url": "https://www.ryjiaoyu.com/book/details/39566",
      "coverImage": "https://cdn-tiny.ryjiaoyu.com/210295c4c9250dd3ff14!screenshow"
    },
    {
      "id": 2,
      "title": "JavaScript修炼之道",
      "author": "聂常红、刘伟",
      "price": "79.80",
      "publisher": "人民邮电出版社",
      "url": "https://www.ryjiaoyu.com/book/details/8966",
      "coverImage": "https://cdn-tiny.ryjiaoyu.com/200326032ab4839a8ef6!screenshow"
    },
    {
      "id": 3,
      "title": "Effective Java中文版",
      "author": "[美] 约书亚·布洛克（Joshua Bloch） 著，臧秀涛 译",
      "price": "99.80",
      "publisher": "人民邮电出版社",
      "url": "https://book.douban.com/subject/36818907/",
      "coverImage": "https://img2.doubanio.com/view/subject/l/public/s34816161.jpg"
    },
    {
      "id": 4,
      "title": "CSS权威指南（第四版）",
      "author": "Eric，A.，Meyer，Estelle，Weyl 著 安道 译",
      "price": "198.00",
      "publisher": "中国电力出版社",
      "url": "https://book.douban.com/subject/33398314/",
      "coverImage": "https://img3.doubanio.com/view/subject/l/public/s32282742.jpg"
    },
    {
      "id": 5,
      "title": "Vue.js前端开发实战",
      "author": "黑马程序员",
      "price": "49.80",
      "publisher": "人民邮电出版社",
      "url": "https://www.ryjiaoyu.com/book/details/48821",
      "coverImage": "https://cdn-tiny.ryjiaoyu.com/23053177f749347bc0c5!screenshow"
    },
    {
      "id": 6,
      "title": "Axure RP 9完全自学教程",
      "author": "苏文学",
      "price": "119.00",
      "publisher": "北京大学出版社",
      "url": "https://book.douban.com/subject/35597812/",
      "coverImage": "https://bkimg.cdn.bcebos.com/pic/f2deb48f8c5494eef01ffcee98a6f7fe9925bd31d0b2?x-bce-process=image/format,f_auto"
    },
    {
      "id": 7,
      "title": "React学习手册（第二版）",
      "author": "[美] 亚历克斯.班克斯，[美] 伊夫.波尔切洛，安道 著",
      "price": "98.00",
      "publisher": "中国电力出版社",
      "url": "https://www.bookschina.com/8618739.htm",
      "coverImage": "https://image12.bookschina.com/2021/20210810/1/8618739.jpg"
    }
  ];
console.log(books);
  // 函数：为每条图书信息生成一行表格
function generateTableRows(books) {
    const tableBody = document.getElementById('booksTableBody');
    books.forEach(book => {
        const row = document.createElement('tr');
        
        const titleCell = document.createElement('td');
        const titleLink = document.createElement('a');
        titleLink.href = book.url;
        titleLink.target = '_blank';
        titleLink.textContent = book.title;
        titleCell.appendChild(titleLink);
        
        const authorCell = document.createElement('td');
        authorCell.textContent = book.author;
        
        const priceCell = document.createElement('td');
        priceCell.textContent = book.price;
        
        const publisherCell = document.createElement('td');
        publisherCell.textContent = book.publisher;
        
        row.appendChild(titleCell);
        row.appendChild(authorCell);
        row.appendChild(priceCell);
        row.appendChild(publisherCell);
        
        tableBody.appendChild(row);
    });
}

// 在页面加载完成后生成表格行
window.onload = function() {
    generateTableRows(books);
};